<template>
  <div class="help">
    <el-table :data="tableData" style="width: 100%" :border="true" :stripe="true">
      <el-table-column :align="'center'" prop="name" label="用途" width="216">
      </el-table-column>
      <el-table-column :align="'center'" prop="command" label="命令">
      </el-table-column>
      <el-table-column :align="'center'" label="操作" width="100">
        <template v-slot="scope">
          <el-button size="mini" @click="handleCopy(scope?.row?.command ?? '--')" class="el-icon-document-copy">
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import util from '@/util'
export default {
  props: {},
  components: {},
  data() {
    return {
      tableData: [
        {
          name: '创建表',
          command: 'create \'表名\', \'列族名1\', \'列族名2\''
        },
        {
          name: '获取数据',
          command: 'get \'表名\', \'行键\', \'列族名:列名\''
        },
        {
          name: '添加数据',
          command: 'put \'表名\', \'行键\', \'列族名:列名\', \'值\''
        },
        {
          name: '查看所有表',
          command: 'list'
        },
        {
          name: '查看表结构',
          command: 'desc \'表名\''
        },
        {
          name: '删除列',
          command: 'delete \'表名\', \'行键\', \'列族名:列名\''
        },
        {
          name: '删除一行数据',
          command: 'delete \'表名\', \'行键\''
        },
        {
          name: '删除表',
          command: 'drop \'表名\' 删除表前需禁用表'
        },
        {
          name: '清空表数据',
          command: 'truncate \'表名\''
        },
        {
          name: '查询所有数据',
          command: 'scan \'表名\''
        },
        {
          name: '查询前2条数据',
          command: 'scan \'表名\', {LIMIT=>2}'
        },
        {
          name: '范围查询',
          command: 'scan \'表名\', {STATROW=>\'起始行键名\', ENDROW=>\'结束行键名\'}'
        },
        {
          name: '统计表记录',
          command: 'count \'表名\', {INTERVAL=>多少行显示一次, CACHE=>每次取的大小}'
        },
        {
          name: '增加列族',
          command: 'alter \'表名\', {NAME=>\'列族名\'}'
        },
        {
          name: '删除列族',
          command: 'alter \'表名\', \'delete\'=>\'列族名\''
        },
        {
          name: '禁用表',
          command: 'disable \'表名\''
        },
        {
          name: '启用表',
          command: 'enable \'表名\''
        },
        {
          name: '判断表是否存在',
          command: 'exists \'表名\''
        }
      ]
    }
  },
  computed: {
  },
  watch: {},
  methods: {
    handleCopy(text) {
      util.copyText(text)
      this.$message({ type: 'success', message: `已复制命令:  ${text}` })
    }
  },
  beforeCreate() { },
  created() { },
  beforeDestroy() { },
  destroyed() { }
}
</script>
<style lang="scss" scoped>
.help {
  &:hover {
    box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.05)
  }
}
</style>